import { createRouter, createWebHistory } from "vue-router";
import Login from "@/views/Login.vue";
import Layout from "@/views/Layout.vue";
import UserInfo from "@/views/user/UserInfo.vue";
import AdminList from "@/views/user/AdminList.vue";
import RestPassword from "@/views/user/RestPassword.vue";
import Cover from "@/views/Cover.vue";
import ChangePassword from "@/views/user/ChangePassword.vue";
import DoorplateApply from "@/views/apply/DoorplateApply.vue";
import DoorplateApproval from "@/views/apply/DoorplateApproval.vue"
import showNews from "@/views/news/showNews.vue"
import AdministrativeDivisions from "@/views/user/AdministrativeDivisions.vue"
import SystemLog from "@/views/user/SystemLog.vue";
import UserList from "@/views/user/UserList.vue";
import DoorplateQuery from "../views/doorplate/DoorplateQuery.vue";
import DashBoard from "@/views/user/DashBoard.vue";
import Register from "@/views/register.vue";
import BannerList from "@/views/banner/BannerList.vue";

// 定义路由关系
const routes = [
  {
    path: '/login',
    component: Login
  },  // 一级路由
  {
    path: '/',
    redirect: '/login',  // 重定向
    component: Layout,
    // 子路由
    children: [
      { path: '/admin/list', component: AdminList },
      { path: '/user/info', component: UserInfo },
      { path: '/user/resetPassword', component: RestPassword },
      { path: '/user/changePassword', component: ChangePassword },
      { path: '/user/doorplateApply', component: DoorplateApply },
      { path: '/user/doorplateApproval', component: DoorplateApproval },
      { path: '/news', component: showNews },
      { path: '/user/AdministrativeDivisions', component: AdministrativeDivisions },
      { path: '/user/SystemLog', component: SystemLog },
      { path: '/dashboard/doorplate-query', component: DoorplateQuery },
      { path: '/user/list', component: UserList },
      { path: '/DashBoard', component: DashBoard },
      { path: '/banner', component: BannerList }
    ]
  },
  {
    path: '/register',
    component: Register
  },
  {
    path: '/cover',
    component: Cover
  },
]

// 创建路由器
const router = createRouter({
  history: createWebHistory(), // 路由模式
  routes: routes
})

//导出暴露
export default router
